<include file="Public/common" />
<block name="css">
    <style>
        input class="form-control"::-webkit-outer-spin-button,
        input class="form-control"::-webkit-inner-spin-button{
            -webkit-appearance: none !important;
            margin: 0;
        }
        .bloder{
            font-weight: bold;
            text-align: right;
        }
        .col-xs-12{
            margin-bottom: 10px;
        }
        .col-xs-12:after{
            content: '';
            display: table;
            height: 0;
            clear: both;
        }
    </style>
</block>
<block name="content">
    <div class="page-header"><h1>首页 > 财务管理 &gt;营业收入总报表</h1></div>
    <div class="tab-content clearfix">
        <div class="row" >
            <form action="" id="settlement-form" class="form-inline"  style="margin-left:10px;" >
                <div class="col-xs-12">
                    <div class="col-xs-4">
                        <label for="" class="col-xs-4 bloder">团号：</label>
                        <div class="col-xs-8"><input class="form-control" type="text" name="group_num" value="<if condition="$_GET['group_num']">{$_GET['group_num']}</if>" /></div>
                    </div>
                    <div class="col-xs-4">
                        <label for="" class="col-xs-4 bloder">线路名称：</label>
                        <div class="col-xs-8"><input class="form-control" type="text" name="line_name" value="<if condition="$_GET['line_name']">{$_GET['line_name']}</if>" /></div>
                    </div>
                    <div class="col-xs-4">
                        <label for="" class="col-xs-4 bloder">运营性质：</label>
                        <div class="col-xs-8">
                            <select name="platform">
                                <option value="">全部</option>
                                <option <if condition="$_GET['platform'] == 1">selected</if> value="1">自营</option>
                                <option <if condition="$_GET['platform'] == 2">selected</if> value="2">非自营</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-xs-12">
                        <div class="col-xs-4">
                            <label for="" class="col-xs-4 bloder">下单时间：</label>
                            <div class="col-xs-4">
                                <input class="form-control" type="text" id="start" name="strat" value="<if condition="$_GET['start']">{$_GET['start']}</if>" />
                            </div>
                            <div class="col-xs-4">
                                <input class="form-control" type="text" id="end" name="end" value="<if condition="$_GET['end']">{$_GET['end']}</if>" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-xs-8"  style="margin-bottom: 0;">
                    <a href="{:U('outBusinessStatement')}" class="btn btn-primary">导出</a>
                    <button type="submit" class="btn btn-primary submit-btn">查询</button>
                    <div class="dropdown open" style="display: inline-block">
                        <button type="button" class="btn btn-primary dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown">筛选<span class="caret"></span></button>
                        <ul id="menuList" class="dropdown-menu pull-right" role="menu" aria-labelledby="dropdownMenu1" style="padding:10px;"></ul>
                    </div>
                </div>
                <div class="col-xs-4 text-right text-danger bloder">
                    合计金额：&#165;{$sum_money} &nbsp; 合计毛利：&#165;{$profit}
                </div>
            </form>
        </div>
        <table id="table" class="table table-striped table-bordered table-hover table-condensed mt-15">
            <thead>
                <tr>
                    <th>订单信息</th>
                    <th>成团时间</th>
                    <th>该团总人数</th>
                    <th>附加产品收入</th>
                    <th>营业额</th>
                    <th>总成本</th>
                    <!-- <th>附加产品成本</th> -->
                    <th>毛利</th>
                    <th>毛利率</th>
                </tr>
            </thead>
            <tbody>
                <volist name="list" id="v" key="i">
                    <tr>
                        <td>
                            团号：{$v.group_num}<br>
                            线路名称：{$v.line_name}
                            <if condition ="$v['platform'] eq 1">(自营)
                            <elseif condition="$v['platform'] eq 2"/>(非自营)
                            </if>
                        </td>
                        <td>{$v['group_time']}</td>
                        <td>{$v['sum(total_num)']}</td>
                        <!-- <td>
                            成人：{//$v.adult_price}<br>
                            儿童：{//$v.child_price}<br>
                            老人：{//$v.oldMan_price}
                        </td> -->
                        <td>{$v['add_income']}</td>
                        <td>{$v['sum(total_money)']}</td>
                        <td>{$v['closing_total_money']}</td>
                        <td>{$v['profit']}</td>
                        <td>{$v['profit_precent']}</td>
                    </tr>
                </volist>

            </tbody>
        </table>
    </div>
    <div class="modal fade" id="bjy-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
                    <h4 class="modal-title" id="myModalLabel"> 外币结算</h4></div>
                <div class="modal-body">
                    <form id="bjy-form" class="form-inline" action="{:U('Finance/singleForeignSettlement')}" method="post">
                        <input class="form-control" type="hidden" name="order_id" id="order_id">
                        <table class="table table-striped table-bordered table-hover table-condensed">
                            <tr>
                                <th width="17%">结算金额：</th>
                                <td><span class="total_money"></span></td>
                            </tr>
                            <tr>
                                <th>汇率：</th>
                                <td><input class="form-control" class="input class="form-control"-medium" type="text" id="settlement_rate" name="settlement_rate" placeholder="请输入汇率"></td>
                            </tr>
                            <tr>
                                <th>实收金额：</th>
                                <td><input class="form-control" class="input class="form-control"-medium" type="text" id="end_foreign_money" name="end_foreign_money" value="0" placeholder="请输入实际收取的金额"><span class="currency_type"></span></td>
                            </tr>
                            <tr>
                                <th>实收人民币：</th>
                                <td><input class="form-control" class="input class="form-control"-medium" readonly type="text" name="end_need_pay"></td>
                            </tr>
                            <tr>
                                <th></th>
                                <td><input class="form-control" class="btn btn-success" type="submit" value="修改"></td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
 <ul class="pagination">{$show}</ul>
</block>
<block name="js">
<script src="__JS__/jedate/jedate.js"></script>
<script>

    /**
     * 绑定日期选择器
     * @param  {[obj]}    obj        [元素]
     * @param  {[string]} dateFormat [时间格式]
     */
    function dateFormat(obj, dateFormat){
        jeDate({
            dateCell: '#'+$(obj).attr('id'),
            format: dateFormat,
            isinitVal:false,
            isTime:true, //isClear:false,
            okfun:function(val){
            }
        });
    }
   dateFormat($('#start'), 'YYYY-MM-DD');
   dateFormat($('#end'), 'YYYY-MM-DD');

     //生成筛选菜单
    (function(){
        var str = '';
        $('#table').find('tr').eq(0).find('th').each(function(i, n){
            str += '<li><input type="checkbox" class="filtrate" checked="" value="'+i+'" id="filtrate_'+i+'"><label for="filtrate_'+i+'">'+$(n).html()+'</label></li>';
        })
        $('#menuList').append(str);
    }())

    $('#menuList').on('change', '.filtrate', function(){
        var index = $(this).val();
        if($(this).prop('checked')){
            $('#table tr').each(function(i,n){  $(n).children().eq(index).show(); })
        }else{
            $('#table tr').each(function(i,n){  $(n).children().eq(index).hide();})
        }
    })
</script>
</block>
